<!DOCTYPE html>
<html lang="en">
<head>
	<{include file="header.html"}>
	<title><{$action}>-<{$user_data['school_name']}>-德安信会计在线教育平台</title>
	<link href="/static/public/webupload/webuploader.css" rel="stylesheet">
	<link href="/static/public/webupload/style.css" rel="stylesheet">
	<script type="text/javascript" src="/static/public/webupload/webuploader.js"></script>
	<script type="text/javascript" src="/static/public/webupload/upload.js"></script>
	<script type="text/javascript">
		var fileNumLimit = 1;
	</script>
	<script type="text/javascript" charset="utf-8" src="/static/public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/public/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/static/public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<div class="wrap">
	<!--star left-->
	<div class="column">
		<{include file="left_menu.html"}>
	</div>
	<div id="ContMianBox">
		<!--star子栏目-->
            <{include file="left_menu_min.html"}>
        <!--end子栏目-->
		<!--end left-->
		<div class="container narrow">
			<!--star conter-->
			<div class="cetContent">
				<div class="tit p-lr20">
					<span><a href="/news">资讯列表</a></span>
				    <span class="curr">添加资讯</span>
				</div>
		<!--star内容区域-->
		<div class="mainScroll">
			<div class="mainContainer line-all">
				<!--star 001-->
				<form class="layui-form layui-form-pane" method="post" action="<{$post_url}>" id="form_add_role">
					<input type="hidden" name="id" value="<{$news_info['id']|default:'0'}>" />
					<div class="layui-form-item">
						<label class="layui-form-label">标题</label>
						<div class="layui-input-block">
							<input type="text" name="title" value="<{$news_info.title|default:''}>" lay-verify="required" autocomplete="off" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">作者</label>
							<div class="layui-input-block">
								<input type="text" name="author" value="<{$news_info.author|default:''}>" lay-verify="required" autocomplete="off" class="layui-input">
							</div>
					</div>

					<div class="layui-form-item">

						<div class="layui-inline">
							<label class="layui-form-label">顶级分类</label>
							<div class="layui-input-block" style="width:500px;">
								<select id="top_category_id" name="top_category_id" lay-filter="category">
									<option value="0">请选择分类</option>
									<{foreach from=$top_category item=top_cate_item}>
									<option value="<{$top_cate_item.id}>" <{if $top_cate_item.id == $news_info.top_category_id|default:""}> selected <{/if}>><{$top_cate_item.name}></option>
									<{/foreach}>
								</select>
							</div>
						</div>

						<div class="layui-inline" id="category_id_box" <{if !isset($category)}>style="display: none;"<{/if}>>
							<label class="layui-form-label">二级分类</label>
							<div class="layui-input-block" style="width:500px;">
								<select id="category_id" name="category_id" >
									<{if isset($category)}>
										<{foreach from=$category item=item}>
										<option value="<{$item.id}>" <{if $item.id == $news_info.category_id|default:""}> selected <{/if}>><{$item.name}></option>
										<{/foreach}>
									<{else}>
									<option value="0" <{if 0 == $news_info.top_category_id|default:""}> selected <{/if}>>分类1</option>
									<option value="1" <{if 1 == $news_info.top_category_id|default:""}> selected <{/if}>>分类2</option>
									<{/if}>
									
								</select>
							</div>
						</div>

					</div>

					<!-- <div class="layui-form-item">
						<label class="layui-form-label">类型</label>
						<div class="layui-input-block">
							<select name="news_type" lay-filter="q_type" <{if $news_info.type|default:"" > 0}> disabled <{/if}>>
								<option value="0" <{if 0 == $news_info.type|default:""}> selected <{/if}>>资讯</option>
								<option value="1" <{if 1 == $news_info.type|default:""}> selected <{/if}>>帮助</option>
							</select>
						</div>
					</div> -->

					<div class="layui-form-item">
						<label class="layui-form-label">是否启用</label>
						<div class="layui-input-block">
								<{assign var="status" value=$news_info.status|default:"1"}>
								<input type="checkbox" <{if $status == 1}> checked <{/if}> name="status" lay-skin="switch" lay-filter="switchTest" value="1" >
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">排序</label>
							<div class="layui-input-block">
								<input type="text" name="sort" value="<{$news_info.sort|default:'0'}>" autocomplete="off" class="layui-input">
							</div>
					</div>

					<div class="layui-form-item layui-form-text">
						<input type="hidden" id="token" value="<{'VIMG'|get_qiniu_token}>" />
						<label class="layui-form-label">封面图</label>
						<div class="layui-input-block" style="margin-top: 5px;">
							<div id="uploader2" class="upload_box" style="float:left; width:420px;">
								<div class="queueList">
									<div id="dndArea2" class="placeholder dndArea">
										<div id="filePicker2" class="filePicker"></div>
										<p>或将照片拖到这里，最多可上传<script>document.write(fileNumLimit);</script>张图片</p>
									</div>
								</div>
								<div class="statusBar" style="display:none;">
									<div class="progress">
										<span class="text">0%</span>
										<span class="percentage"></span>
									</div><div class="info"></div>
									<div class="btns">
										<div id="filePickerBut2" class="filePickerBut"></div><div class="uploadBtn">开始上传</div>
									</div>
								</div>
								<div class="upload_img_input" input_name='news_images'></div>
							</div>
							<{if isset($news_info['news_images']) AND $news_info['news_images'] != ''}>
								<div class="layui-inline" style="float:left;"><img src="<{$news_info['news_images']}>" style="max-height:175px;"/></div>
							<{/if}>
						</div>
					</div>

					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">摘要</label>
						<div class="layui-input-block">
							<textarea name="paper" class="layui-textarea"><{$news_info.paper|default:""}></textarea>
						</div>
					</div>

					<div class="layui-form-item layui-form-text" id="text_subject_text">
						<label class="layui-form-label">内容</label>
						<div class="layui-input-block">
							<!-- 加载编辑器的容器 -->
						    <script id="container" name="content" type="text/plain">
						        <{$news_info.content|default:""}>
						    </script>
						    <!-- 配置文件 -->
						    <script type="text/javascript" src="/static/public/ueditor/ueditor.config.js"></script>
						    <!-- 编辑器源码文件 -->
						    <script type="text/javascript" src="/static/public/ueditor/ueditor.all.js"></script>
						    <!-- 实例化编辑器 -->
						    <script type="text/javascript">
						        var ue = UE.getEditor('container');
						    </script>
						</div>
					</div>

					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</form>
				<!--end 001-->
				
			</div>
			
		</div>
		<!--end内容区域-->
		</div>
	</div>
</div>
<{include file="footer.html"}>
<script type="text/javascript">
	layui.use(['form','jquery'], function(){
		var form = layui.form(),$ = layui.jquery;
		form.on('select(category)', function(data){
			var ii = layer.load();
			var category_id = $(data.elem).val();
			$("#category_id").html('<option value="">请选择二级分类</option>');  
			form.render('select');
			$.ajax({
				type: "POST",
				url: "/news/ignore_get_children_category",
				dataType:"json",
				data:{category_id:category_id},
				success: function(result){
					layer.close(ii);
					if(result.code == 1){
						$("#category_id_box").show();
						var html ='';
						$.each(result.category_list, function(i, obj) {
							html += '<option value="'+obj.id+'">'+obj.name+'</option>';
						});
						$("#category_id").append(html);
						form.render('select');
					}else{
						$("#category_id_box").hide();
					}
				}
			});
		});
	});
</script>
</body>
</html>



